﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting;
using System.Text;
using System.Threading.Tasks;
using GurLoader.Service.ImgurTaskBuilder;
using GurLoader.Util;
using Imgur.Net;
using NUnit.Framework;

namespace GurLoaderWPF.Test.Util
{
    [TestFixture]
    public class LinkHelperTests
    {
        [Test]
        public void GetLinkUrlNullObjectTest()
        {
            string link = LinkHelper.GetLinkUrl((object) null);
            Assert.IsNullOrEmpty(link);
        }

        [Test]
        public void GetLinkUrlNonInfoObjectTest()
        {
            object o = new object();
            string link = LinkHelper.GetLinkUrl(o);

            Assert.IsNullOrEmpty(link);
        }

        [Test]
        public void GetLinkUrlAlbumInfoWithLinkPropertyTest()
        {
            string testLink = "http://a.com/b/c/d.html";

            AlbumInfo info = new AlbumInfo("12345", string.Empty, string.Empty, DateTime.Now, LayoutStyle.Blog, 0,
                testLink, string.Empty);
            AlbumUploadResult result = new AlbumUploadResult(info);

            string link = LinkHelper.GetLinkUrl(result);

            Assert.IsNotNullOrEmpty(link);
            Assert.AreEqual(testLink, link);
        }

        [Test]
        public void GetLinkUrlAlbumInfoWithIdPropertyTest()
        {
            AlbumInfo info = new AlbumInfo("12345", string.Empty, string.Empty, DateTime.Now, LayoutStyle.Blog, 0,
                string.Empty, string.Empty);

            AlbumUploadResult result = new AlbumUploadResult(info);
            string link = LinkHelper.GetLinkUrl(result);

            Assert.IsNotNullOrEmpty(link);
            StringAssert.Contains("12345", link);
        }

        [Test]
        public void GetLinkUrlImageInfoWithLinkPropertyTest()
        {
            string testLink = "http://a.com/b/c/d.html";
            ImageInfo info = new ImageInfo("12345", string.Empty, string.Empty, DateTime.Now, string.Empty, false, 100,
                100, 100000, 0, 0, string.Empty, string.Empty, testLink, false, false, string.Empty);

            ImageUploadResult result = new ImageUploadResult(info);
            string link = LinkHelper.GetLinkUrl(result);

            Assert.IsNotNullOrEmpty(link);
            Assert.AreEqual(testLink, link);
        }

        [Test]
        public void GetLinkUrlImageInfoWithIdPropertyTest()
        {
            ImageInfo info = new ImageInfo("12345", string.Empty, string.Empty, DateTime.Now, string.Empty, false, 100,
                100, 100000, 0, 0, string.Empty, string.Empty, string.Empty, false, false, string.Empty);
            ImageUploadResult result = new ImageUploadResult(info);

            string link = LinkHelper.GetLinkUrl(result);

            Assert.IsNotNullOrEmpty(link);
            StringAssert.Contains("12345", link);
        }
    }
}
